<template>
  <div>
      <div v-for=" i in class_list" :key="i.id">
          <h3><router-link :to="{'path':'/show','query':{'id':i.id}}">班级名{{i.name}}</router-link></h3>
      </div>

      <div>
          <input type="button" @click="btn(cur_num-1)" value="上一页">
          <input type="button" v-for="num in page_list" :key="num" @click="btn(num)" :value="num">
          <input type="button" @click="btn(cur_num+1)" value="下一页">
      </div>
  </div>
</template>

<script>
import axios from 'axios'
export default {
    data(){
        return{
            class_list:[],
            page_list:[],
            cur_num:1
        }
    },created(){
        this.btn(1)
    },
    methods:{
        btn(num){
            this.cur_num=num
           axios.get('http://127.0.0.1:8000/addclass?num='+num).then(resp=>{
               console.log(resp.data)
               this.class_list=resp.data.data
               this.page_list=resp.data.class_list
           }).catch(error=>{
               console.log(error)
           })
        }
    }
}
</script>

<style>

</style>